var express = require('express');
var router = express.Router();
const { get, put, address, deleteId, post} = require("../api/indent");

// 获取订单数据
router.get('/get', async function (req, res, next) {
    const { userId, genre } = req.query;
    const data = await get({ userId, genre });
    console.log(data);
    res.send(data);
});
// 更新订单状态
router.put('/put', async function (req, res, next) {
    const { Id } = req.body;
    const data = await put({ Id });
    res.send(data);
});
// 判断用户是否有自提点
router.get('/address', async function (req, res, next) {
    const { userId } = req.query;
    const data = await address({ userId });
    res.send(data);
});
// 删除订单
router.delete('/delete', async function (req, res, next) {
    const { Id } = req.body;
    console.log(Id);
    const data = await deleteId({ Id });
    res.send(data);
});
// 新增订单
router.post('/post', async function (req, res, next) {
    const { userId, information, total, time, state } = req.body;
    console.log(userId, information, total, time, state);
    const data = await post({ userId, information, total, time, state});
    if (data) {
        res.send(true);
    }else{
        res.send(false);
    }
});
module.exports = router;